package com.bokesoft.yes.mid.cmd.richdocument.strut;

import java.util.HashMap;

import com.bokesoft.yes.mid.base.IMidVEFactory;
import com.bokesoft.yes.mid.cmd.IServiceCmd;
import com.bokesoft.yes.mid.cmd.ReloadFormCmd;
import com.bokesoft.yes.mid.service.GeneralService;
import com.bokesoft.yigo.mid.base.DefaultContext;
import com.bokesoft.yigo.mid.base.IServiceContext;
import com.bokesoft.yigo.mid.service.IServiceProvider;
/**
 * 配置：Enhance.xml
 * 	<ExtSysService>
 *		<Service Name="RichDocumentService" Impl="com.bokesoft.yes.mid.cmd.richdocument.strut.RichDocumentService"/>
 *	</ExtSysService>
 * @author USER
 *
 */
public class RichDocumentService  extends GeneralService<DefaultContext> {
	@Override
	public String getServiceName() {
		return "RichDocument";
	}
	
	@Override
	protected Object[][] getCmdImplTable() {
		System.out.println("RichDocumentService.getCmdImplTable()");
		return new Object[][] {
				{ ReloadFormCmd.CMD, new ReloadFormCmd() }
				};
	}

	@Override
	protected IServiceCmd<DefaultContext> getDefaultImpl() {
		return null;
	}

	@SuppressWarnings("unchecked")
	@Override
	public IServiceCmd<DefaultContext> getPrototype(DefaultContext context,
			String cmd) {
		return (IServiceCmd<DefaultContext>)RichDocumentService.prototype.get(cmd);
	}

	@Override
	public IServiceProvider<DefaultContext> newInstance() {
		return new RichDocumentService();
	}
	
	public static HashMap<String, IServiceCmd<?>> prototype = null;
	static {
		RichDocumentService.prototype = new HashMap<String, IServiceCmd<?>>();
		GeneralService.initPrototype(RichDocumentService.prototype, new RichDocumentService());
//		try {
			//Class.forName("com.bokesoft.yes.mid.cmd.richdocument.fun.ERPFunctionUtil").getMethod("registerERPMidFunction").invoke(null);
			//ERPFunctionUtil.registerERPMidFunction();
//		} catch (Throwable e) {
//			e.printStackTrace();
//		}
	}

	@Override
	public IServiceContext newServiceContext(IMidVEFactory veFactory) throws Throwable {
		DefaultContext context = new DefaultContext(veFactory.createVE());
		return context;
	}
}